<%@ page language="java" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>用户留言</title>
<script type="text/javascript" src="js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="xheditor-1.1.6/xheditor-1.1.6-zh-cn.min.js"></script>
<link rel="shortcut icon" href="images/chinaunicom.ico"/>
<link href="css/user.css" rel="stylesheet" type="text/css"/>
<style type="text/css">
input{
	border:1px solid #EEE;
	width:220px;
	height:20px;
	line-height:18px;
	vertical-align: middle;
}
</style>


<script type="text/javascript">
	
	$(document).ready(function(){
		  
		$('#messageContent').xheditor({tools:'simple',skin:'vista'});
		
	});
	function doSubmit(){
		var email=$('#email').val();
		var regex = /^[A-Za-z0-9+]+[A-Za-z0-9\.\_\-+]*@([A-Za-z0-9\-]+\.)+[A-Za-z0-9]+$/;
		if(!email.match(regex)){
			alert('邮箱格式非法')
			return ;
		}
		var msg = $('#messageContent').val();
		if(msg.length<10){
			alert('字符太少啦(最少10个字符哦~)');
			return ;
		}
		if($('#validateImg').length>0){
			var code = $('#vlidateCode').val();
			if(code.length<1){
				alert('请输入验证码');
				return ;
			}
		}
		var btnSubmit = $('#btnSubmit');
		btnSubmit.disabled=true;
		$.post('message!save.action',$('#msgForm').serialize(),function(result){
			btnSubmit.disabled=false;
			if(result.success){
				var _html = '<br/><br/><br/><font style="font-weight:bold">您的留言已提交,谢谢您的支持!</font><br/><br/>';
				_html+='3s后转至<a href="user!viewDetailPage.action">流量查询页</a>';
				$('#msgFormDiv').html(_html);
				setTimeout(function(){
					window.location.href='user!viewDetailPage.action';
				},3000);
			} else {
				alert(result.data);
			}
		},'json');
	}
	
	function flushValidateImg(){
		$('#validateImg').attr('src','validateImg.jsp?d='+new Date().getTime());
	}
</script>

</head>

<body>

<div id="main">
	
	<div class="panel-center" style="width:600px;margin:0 auto;text-align:center">
		<div class="panel-title"><span style="float:left;padding-left:10px">中国联通</span>
			<span><a href="javascript:void(0)" onclick="window.close();" style="float:right;padding-right:10px;color:#111" title="点击关闭">关闭 </a></span>
		</div>
		
		<div class="panel-body" id="msgFormDiv">
			<form id="msgForm">
				<div style="padding:10px;float:left;">
					<span>昵称:<input type="text" name="entity.username"/></span>
					<span><font style="color:red">*</font>邮箱:<input type="text" id="email" name="entity.email"/></span>
				</div>
				<div style="padding:10px">
					<textarea name="entity.content" id="messageContent" rows="5" style="width:100%;height:300px;"></textarea>
				</div>
				<div style="width:30%;float: left;">&nbsp;</div>
				<div style="width:38%;float: left;text-align: center;"><input type="button" value="返回" class="btn green" style="width:80px;height:30px" onclick="window.history.go(-1)" />&nbsp;&nbsp;<input type="button" id="btnSubmit" value="提交" class="btn blue" style="width:80px;height:30px" onclick="doSubmit();" />
				</div>
				<div style="width:30%;float: left;">
					<%if (request.getSession().getAttribute(com.wlanauth.web.core.SystemConstants.SESSION_USER_KEY)==null){ %>
						验证码:<input type="text"  id="vlidateCode" name="vlidateCode" style="border:none;border-bottom:1px solid #fff;background:none;width:50px" />&nbsp;<img src="validateImg.jsp" alt="验证码(忽略大小写)" style="float:right" onclick="flushValidateImg()" id="validateImg"/>
					<%} %>
				</div>
			</form>
		</div>
	</div>
	

</div>

<!--main end-->

<!--footer end-->

</body>
</html>
